﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for DALBranch
/// </summary>
public class DALBranch : BaseDAL
{
	public DALBranch()
	{
		
	}

    public List<tblBranch> ListBranches()
    {
        return db.tblBranches.ToList();
    }

    public List<tblBranch> ListBranches(string barcode)
    {
        List<tblBranch> lst = db.tblBranches.ToList();

        tblPackage package = db.tblPackages.SingleOrDefault(c => c.Barcode == barcode);
        if (package != null)
        {
            foreach (tblTransit t in package.tblTransits)
            {
                  lst.Remove(t.tblBranch);
            }
        }
        return lst;
    }


    internal tblBranch GetBranch(int id)
    {
        return db.tblBranches.SingleOrDefault(c => c.ID == id);
    }
}